<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="梅子">
    <title></title>
<style>
    body{
        margin: 0;
    }
    ul{
        padding: 0;
        margin: 0;
        list-style: none;
    }
    .box{
        margin: 0 auto;
        width: 520px;
        position: relative;
    }
    ul li{
        display: none;
    }
    .current{
        display:block;
    }
    .light{
        width: 200px;
        position: absolute;
        bottom: 30px;
        left:calc(200px - 20px);

    }
    .light span{
        display:inline-block;
        margin: 0 5px;
        width: 15px;
        height: 15px;
        cursor: pointer;
        background-color: red;
        border-radius: 50%;
    }
    .light .green{
        background-color: green;
    }
    .img-click span{
        display: inline-block;
         position: absolute;
        top:100px;
        width: 30px;
        height: 40px;
        line-height: 40px;
        text-align: center;
        font-size: 20px;
        color: white;
        background-color: #aaa;  
        opacity: 0.2;
    } 
    .img-click .prev{
        left:0;
    }
    .img-click .next{
        right:0;
    }



</style>
</head>
<body>
     <div class="box">
          <ul>
              <li class="current"><a href="#"><img src="../img/01.jpg" alt=""></a></li>
              <li><a href="#"><img src="../img/02.jpg" alt=""></a></li>
              <li><a href="#"><img src="../img/03.jpg" alt=""></a></li>
              <li><a href="#"><img src="../img/04.jpg" alt=""></a></li>
              <li><a href="#"><img src="../img/05.jpg" alt=""></a></li>
          </ul>
           <div class="light"> 
          <span class="green"></span>
          <span></span>
          <span></span>
          <span></span>
          <span></span>
      </div>
      <div class="img-click">
            <span class="prev">&lt;</span>
            <span class="next">&gt;</span>
        </div>
      </div>
      <script src="jquery.js"></script> 
</body>
</html>
<script>
    
    var index=0;
    function prevImg(){
        index=index==0 ? $('ul li').length:index-1; 
        showImg()
    }
    function nextImg(){
       index=index==$('ul li').length ? 0:index+1; 
       showImg()
    }
    var timer=setInterval(nextImg,1000)
     function showImg(){
      $('ul li').eq(index).addClass('current').
        siblings().removeClass('current');
        $('.light span').eq(index).addClass('green')
        .siblings().removeClass('green');

     }
    
     $('.box').hover(function(){
         clearInterval(timer);
         timer=null;
           $('.img-click span').fadeTo(1000,0.7);   
     },function(){
          timer=setInterval(nextImg,1000);
          $('.img-click span').fadeTo(1000,0.2);
          
     })

       $('.light span').mouseover(function(){
           index=$(this).index();
           showImg();
            })
         
        $('.next').click(function(){
            nextImg()
        })
         $('.prev').click(function(){
            prevImg()
        })
       


        
</script>